﻿///////////////////////////////////////////////////////
//
// XDesigner.ORM 
//
// autohr : yuans
//
// date: 2011-2-23
//
// email  : yyf9989@hotmail.com
// 
//
///////////////////////////////////////////////////////

using System;
using System.Text;

namespace XDesigner.ORM
{
    /// <summary>
    /// Special id genereate style
    /// </summary>
    [AttributeUsage( AttributeTargets.Property )]
    public class ORMNewValueGenerateAttribute : Attribute 
    {
        public ORMNewValueGenerateAttribute(ORMNewValueGenerateStyle style)
        {
            _Style = style;
        }

        public ORMNewValueGenerateAttribute(ORMNewValueGenerateStyle style, string format)
        {
            _Style = style;
            _Format = format;
        }

        private ORMNewValueGenerateStyle _Style = ORMNewValueGenerateStyle.None ;
        public ORMNewValueGenerateStyle Style
        {
            get
            {
                return _Style;
            }
            set
            {
                _Style = value;
            }
        }

        private string _Format = null;

        public string Format
        {
            get { return _Format; }
            set { _Format = value; }
        }
    }

    public enum ORMNewValueGenerateStyle
    {
        /// <summary>
        /// Do nothing
        /// </summary>
        None,
        /// <summary>
        /// Auto increase 
        /// </summary>
        Increase ,
        /// <summary>
        /// GUID
        /// </summary>
        GUID,
        /// <summary>
        /// Use current date
        /// </summary>
        CurrentDate ,
        /// <summary>
        /// Use current date and time
        /// </summary>
        CurrentDateTime,
        /// <summary>
        /// Call class's method , default name is "Generate_property name",
        /// the method without any parameter
        /// </summary>
        LocalMethod ,
        /// <summary>
        /// Custom generate id of new record
        /// </summary>
        Custom
    }
}
